package cn.byapps.hw.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * 老师上传文件基类
 */
@Entity
@Table(name = "teacherFile")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "Assignment_type")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class TeacherFile implements Serializable {

    @Id
    @GeneratedValue(generator = "uuid")
    @GenericGenerator(name = "uuid", strategy = "uuid")
    @Column(name = "id", length = 64)
    protected String id;// 文件唯一id,uuid
    @Column(name = "fileName", length = 100)
    protected String fileName;// 文件上传名称
    @Column(name = "filePath", length = 250)
    protected String filePath;// 文件保存路径
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "fileDate")
    protected Date fileDate = new Date();// 上传时间
    @Column(name = "size", scale = 2) // 两位小数点
    protected Double size;// 文件大小
    @ManyToOne
    @JoinColumn(name = "homework_id")
    private Homework homework;
}
